import { PageReqVO } from '@/types/request'
import request from '@/util/http/index'

export interface DSource {
  id: number
  url: string
  name: string
  refreshInterval: number
  varDefineType: 0 | 1
  varDefine: string
}

interface IPageVo extends DSource, PageReqVO {}
/**
 * 保存新数据源
 */
export const createDataSource = async (data: HFileMeta) => {
  return await request.post({
    url: '/crc/svg-data-source/create',
    data
  })
}

/**
 * 获取数据源详情
 */
export const getDataSource = async (id: number) => {
  return await request.get({
    url: '/crc/svg-data-source/get',
    params: { id }
  })
}
/**
 * 更新数据源信息
 */
export const updateDataSource = async (data: HFileMeta) => {
  return await request.put({
    url: '/crc/svg-data-source/update',
    data
  })
}

/**
 * 删除数据源
 */
export const deleteDataSource = async (id: number) => {
  return await request.delete({
    url: '/crc/svg-data-source/delete',
    params: { id }
  })
}

/**
 * 个月获取
 * @param params
 * @returns
 */
export const getDataSourcePage = async (params: Partial<IPageVo>) => {
  return await request.get({
    url: '/crc/svg-data-source/page',
    params
  })
}
